<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>


<!-- 文件上传需要的样式 -->

<link rel="stylesheet" type="text/css"
	href="${path }/resource/plugin/kindeditor/themes/default/default.css" />
<link rel="stylesheet" type="text/css"
	href="${path }/resource/plugin/kindeditor/plugins/code/prettify.css" />
<script type="text/javascript"
	src="${path }/resource/plugin/kindeditor/kindeditor.js"></script>
<script type="text/javascript"
	src="${path }/resource/plugin/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript"
	src="${path }/resource/plugin/kindeditor/plugins/code/prettify.js"></script>

<title></title>
</head>


<div class="ibox-content">
	<form class="form-horizontal" id="dataform"
		onsubmit="javascripr:return false;">

		<input type="hidden" name="tokenUrl" value="${tokenUrl}"> <input
			type="hidden" name="token" value="${token}">
		<c:if test="${obj ne null }">
			<input type="hidden" name="id" value="${obj.id }">
		</c:if> 

		
		<input type="hidden" name="projId" value="${projId}" >
		<input type="hidden" name="receiveId" id="receiveId">
		
		<div class="form-group">
			<label class="col-sm-2 control-label">报告标题</label> 
			<div class="col-sm-10">
			<input type="text" dataType="*1-20" class="form-control"
					name="title" value="<c:out value='${obj.title}' />" nullmsg="标题不能为空">
					<div class="Validform_checktip"></div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">报告类型</label>
			<div class="col-sm-10">
			<select style="width: 100%" name="type" class="form-control">
			<c:if test="${obj.type eq 项目启动报告}">selected="selected"</c:if>
				<option value="项目启动报告" <c:if test="${obj.type eq 项目启动报告}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;项目启动报告&nbsp;&nbsp;&nbsp;</option>
				<option value="项目中期报告" <c:if test="${obj.type eq 项目启动报告}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;项目中期报告&nbsp;&nbsp;&nbsp;</option>
				<option value="项目首次交付报告" <c:if test="${obj.type eq 项目启动报告}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;项目首次交付报告&nbsp;&nbsp;&nbsp;</option>
				<option value="项目客户验收报告" <c:if test="${obj.type eq 项目启动报告}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;项目客户验收报告&nbsp;&nbsp;&nbsp;</option>
				<option value="项目总结报告" <c:if test="${obj.type eq 项目启动报告}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;项目总结报告&nbsp;&nbsp;&nbsp;</option>
			</select>
			<!-- <input type="text" dataType="*1-20" class="form-control"
					name="projName" value="">
					<div class="Validform_checktip"></div>-->
			</div> 
		</div>
		<c:if test="${obj.receiveId eq null}">
			<div class="form-group">
				<label class="col-sm-2 control-label">接收人:</label>
				<div class="col-sm-8" id="userName">
				<!-- 	<input type="text" dataType="*1-20" class="form-control"
						name="projName" value="">
					<div class="Validform_checktip"></div> -->
				</div>
				<div class="col-sm-2" id="s1"><strong style="color: red">*请选择接收人</strong></div>
			</div>
		</c:if>
		
		<div class="form-group">
			<label class="col-sm-2 control-label">报告内容</label>
			<div class="col-sm-8">
			<textarea name="content" id="artcontent1" >${obj.content}</textarea>
			</div>
			<div class="col-sm-2"></div>
		</div>
		<input type="hidden" name="fileUrl" id="fileUrl" value="${obj.fileUrl}">
		<div class="form-group">
		<label class="col-sm-2 control-label">文件上传</label>
			<div class="col-sm-8">
				<input onclick="MTools.chooesFile('#fileText2')" value="${obj.fileUrl}" 
					class="input-text upload-url radius form-control" type="text" id="showFileName2"
					readonly style="width: 30%;display: inline;"> 
					<a onclick="MTools.chooesFile('#fileText2')" class="btn btn-primary radius"> 
					<i   class="fa fa-cloud-upload"></i> 浏览文件 </a> 
					<input type="button" class='btn btn-primary radius'onclick="MTools.upFile('#submitBtn2')" value="上传"> 
			</div>
		</div>
		
		
		<div class="form-group ">
			<div class="col-sm-12 text-center" >
				<a href="javascript:;" onclick="myForm.submit()"
					class="btn btn-success radius">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
				<button onclick="MTools.closeForm()" class="btn btn-danger radius">取消</button>
			</div>
		</div>
	</form>
	
	<iframe src="" name="blankFrame" id="blankFrame"
				style="height: 100px; width: 100px; display: none;"> </iframe>
	<form class="form form-horizontal" method="post" style="display: none;"
		enctype="multipart/form-data" target="blankFrame" 
	action="${path }/resource/plugin/kindeditor/zking_upload_json.jsp?fileType=file&hiddenId=fileUrl">
		<input id="fileText2" type="file" multiple name="file-1"  onchange="MTools.selectFile('#showFileName2','#fileText2','')" /> 
		<input type="submit" id="submitBtn2"/>
	</form>
</div>

</body>
<script type="text/javascript">
	var editor;
	 var myForm;
	$(function(){
		MUI.createEdit("content", '100%', '500px', 'editor');
		
		 myForm=MForm.initForm({
			invokeUrl:"${path}/admin/report/addOrModify",
			beforeSubmit:function(){
				editor.sync();
			},
			//validform:getReceiveIds(),
			afterSubmit:function(){
				parent.myGrid.serchData();
			},
		});
	})
	
	//接受人
	$(function(){
		var html="";
		$.AjaxProxy({a : false,c : false}).invoke("${path}/admin/report/queryUserName",function(loj){
			for(var i = 0; i < loj.getRowCount(); i++){
			html=html+"<input type='checkbox' name='userId'  dataType='*'  value='"+loj.getString(i,"id")+"' onchange='getReceiveIds()'>"+loj.getString(i,"name")+"&nbsp;&nbsp;&nbsp;&nbsp;"
			}		
		})
		$("#userName").empty().html(html);
	})

	function getReceiveIds(){
		var checkbox=document.getElementsByName("userId");
		var j=0;
		var receiveId="";
		for(var i=0;i<checkbox.length;i++){
			if(checkbox[i].checked){
				j++;
				receiveId+=checkbox[i].value+",";
			}
		}
		$("#receiveId").val(receiveId);
		if(j > 0){
			$("#s1").empty().html("");
		}else{
			$("#s1").empty().html('<strong style="color: red">*请选择接收人</strong>');
		}
	}

</script>
</html>
